#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
    char arr[8001] = { 0 }, i = 0;
    scanf("%s", arr);
    long long c = 0, ch = 0, chn = 0;
    char* p = arr;
    while (*p)
    {
        if (*p == 'C')
            c++;
        else if (*p == 'H')
            ch += c;
        else if (*p == 'N')
            chn += ch;
        p++;
    }
    printf("%lld\n", chn);
    return 0;
}
